package com.chezhujie.www.controller.api;

import com.chezhujie.www.domain.*;
import com.chezhujie.www.enums.Expresstatus;
import com.chezhujie.www.enums.OrderStatus;
import com.chezhujie.www.enums.OrderType;
import com.chezhujie.www.service.*;
import com.xy.core.page.Pagination;
import com.xy.core.utils.LocalDateTime;
import com.xy.core.utils.OrderNumUtils;
import com.xy.core.utils.UUIDUtils;
import com.xy.user.base.controller.BaseController;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.*;


/**
 * Created by 汤伟杰 on 2017/5/8.
 */
@Controller
@RequestMapping("/api/order")
public class OrderController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(OrderController.class);
    @Autowired
    private WeixininfoService weixininfoService;
    @Autowired
    private CzjorderService czjorderService;
    @Autowired
    private CzjactivityService czjactivityService;
    @Autowired
    private CzjtordermemberService czjtordermemberService;
    @Autowired
    private CzjuserinfoService czjuserinfoService;
    @Autowired
    private CzjusermessService czjusermessService;
    @Autowired
    private CzjweixinvoucherService czjweixinvoucherService;
    @Autowired
    private CzjpayorderService czjpayorderService;
    @Autowired
    private CzjawarduseService czjawarduseService;
    @Autowired
    private CzjorderdetailService czjorderdetailService;
    @Autowired
    private CzjcommodityService czjcommodityService;
    @Autowired
    private CzjweixininfoService czjweixininfoService;
    @Autowired
    private CzjawardstockService czjawardstockService;
    @Autowired
    private CzjusecouponService czjusecouponService;
    @Autowired
    private CzjorderdistributionService czjorderdistributionService;
    @Autowired
    private CzjdeliveryaddService czjdeliveryaddService;
    @Autowired
    private CzjcommodityimageService czjcommodityimageService;

    @Autowired
    private CzjexpressService czjexpressService;
    @Autowired
    private CzjbusinessService czjbusinessService;
    @Autowired
    private IdentitycardService identitycardService;


    //未支付时删除订单
    @RequestMapping("delOrderno.jn")
    public void delOrderno(@RequestParam(required = true)String orderNo,//支付订单号
                           Integer userinfoId,
                           HttpServletRequest request, HttpServletResponse response,
                           ModelMap model) throws Exception {
        Map<String, Object> param = new HashMap<>();
        param.put("orderCode", orderNo);
        Czjorder order = czjorderService.getOneBy(param);
        if(order==null){
            jsonResult(0,"301","订单号不存在","",response);
            return ;
        }
        if(userinfoId.equals(order.getUserinfoId())){
            if(OrderStatus.TOBUY.getIndex()==order.getStatus()||OrderStatus.STAYINADVANCE.getIndex()==order.getStatus()){
                czjorderService.deleteAllByOrderCode(orderNo);
                jsonResult(1,"","订单取消成功","",response);
                return ;
            }else{
                jsonResult(0,"303","该订单状态不允许取消订单","",response);
                return ;
            }

        }

        jsonResult(0,"302","订单号和用户匹配不上","",response);
        return ;


    }
    //确认收货
    @RequestMapping("confirmReceipt.jn")
    public void confirmReceipt(@RequestParam(required = true)String orderNo,//支付订单号
                               Integer userinfoId,
                               HttpServletRequest request, HttpServletResponse response,
                               ModelMap model) throws Exception {
        Map<String, Object> param = new HashMap<>();
        param.put("orderCode", orderNo);
        Czjorder order = czjorderService.getOneBy(param);
        if(order==null){
            jsonResult(0,"311","订单号不存在","",response);
            return ;
        }
        if(userinfoId.equals(order.getUserinfoId())){
            if(OrderStatus.TOSENDGOODS.getIndex()==order.getStatus()){
                Czjorder czjorder = new Czjorder();
                czjorder.setId(order.getId());
                if(order.getPurchaseOrLease()==1){
                    czjorder.setStatus(OrderStatus.INLEASE.getIndex());
                    Czjorderdetail czjorderdetail = new Czjorderdetail();
                    czjorderdetail.setOrderCode(orderNo);
                    Calendar   calendar   =   new GregorianCalendar();
                    calendar.setTime(new Date());
                    calendar.add(calendar.DATE,1);//把日期往后增加一天.整数往后推,负数往前移动
                    Date date = calendar.getTime();
                    String date1 = LocalDateTime.getDate(date,"YYYY-MM-dd");
                    czjorderdetail.setRentDate(LocalDateTime.parse(date1+" 00:00:00"));
                    czjorderdetailService.updateByOrderCode(czjorderdetail);
                }else if(order.getPurchaseOrLease()==2){
                    czjorder.setStatus(OrderStatus.FIN.getIndex());
                }else{
                    jsonResult(0,"315","该订单不是购买或者租赁订单","",response);
                    return ;
                }

                czjorderService.update(czjorder);
                jsonResult(1,"","确认收货成功","",response);
                return ;
            }else{
                jsonResult(0,"312","该订单状态不能执行确认收货","",response);
                return ;
            }

        }

        jsonResult(0,"313","订单号和用户匹配不上","",response);
        return ;

    }
    //用户输入运单号

    //根据订单号获取商品信息
  /*  @RequestMapping("getCommodityInfo.jn")
    public void confirmReceipt(@RequestParam(required = true)String orderNo,//支付订单号
                               HttpServletRequest request, HttpServletResponse response,
                               ModelMap model) throws Exception {
        Map<String, Object> param = new HashMap<>();
        param.put("orderCode", orderNo);
        Czjorder order = czjorderService.getOneBy(param);
        if(order==null){
            jsonResult(0,"321","订单号不存在","",response);
            return ;
        }

        Czjorderdetail orderdetail = czjorderdetailService.queryByCode(orderNo);
        if(orderdetail==null){
            jsonResult(0,"322","订单详情不存在","",response);
            return ;
        }
        String commodityId = orderdetail.getCommodityId();
        if(commodityId==null){
            jsonResult(0,"323","商品信息不存在","",response);
            return ;
        }
        //商品头像、商品简介、现价、原价、商品名字、商品图片总数
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("commodityId", commodityId);
        Map<String,Object> data = czjcommodityService.queryDetail(map);

        checkCommodity(data);

        Map<String, Object> param2 = new HashMap<String, Object>();
        param2.put("commodityId", commodityId);
        param2.put("picType", 0);
        List<Map<String, Object>> map2 = czjcommodityimageService.getApiList(param2);
        data.put("imageList",map2);
        //id/imagePath/content/commodityName/originalPrice/presentPrice/soldCount/picCount/commentsCount

        jsonResult(1,"","获取商品详情成功",data,response);

        return ;

    }*/
    private static void checkCommodity(Map<String, Object> data) {
        data.put("status",0);
        if(data.get("soldOut")==null){
            data.put("status", 1);
        }else {
            if(!String.valueOf(data.get("soldOut")).equals("0")){
                data.put("status", 1);
            }
        }

        if(data.get("delFlag")==null){
            data.put("status", 2);
        }else {
            if(!String.valueOf(data.get("delFlag")).equals("0")){
                data.put("status",2);
            }
        }
    }
    //结束租赁(计算要支付的金额)
    @RequestMapping("endLease.jn")
    public void endLease(@RequestParam(required = true)String orderNo,//支付订单号
                         HttpServletRequest request, HttpServletResponse response,
                         ModelMap model) throws Exception {
        try {
            Map<String, Object> param = new HashMap<>();
            param.put("orderCode", orderNo);
            Czjorder order = czjorderService.getOneBy(param);
            if (order == null) {
                jsonResult(0, "321", "订单号不存在", "", response);
                return;
            }
            Czjorderdetail orderdetail = czjorderdetailService.queryByCode(orderNo);
            if (orderdetail == null) {
                jsonResult(0, "322", "订单详情不存在", "", response);
                return;
            }
            if (OrderStatus.INLEASE.getIndex() != order.getStatus()) {
                jsonResult(0, "324", "该订单状态不能执行结束租赁", "", response);
                return;
            }
            Map<String,Object> moneydata = czjorderdetailService.jisuanMoney(orderdetail);
            BigDecimal money = (BigDecimal) moneydata.get("money");
            Integer big = (Integer) moneydata.get("usedate");
            String commodityId = orderdetail.getCommodityId();
            if (commodityId == null) {
                jsonResult(0, "323", "商品信息不存在", "", response);
                return;
            }

            //商品头像、商品简介、现价、原价、商品名字、商品图片总数
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("commodityId", commodityId);
            Map<String, Object> data = czjcommodityService.queryDetail(map);

            checkCommodity(data);

            Map<String, Object> param2 = new HashMap<String, Object>();
            param2.put("commodityId", commodityId);
            param2.put("picType", 0);
            List<Map<String, Object>> map2 = czjcommodityimageService.getApiList(param2);
            data.put("imageList", map2);
            data.put("money", money + "");
            data.put("useDate", big);
            data.put("amount", orderdetail.getAmount());
            data.put("dailyRent", String.valueOf(data.get("dailyRent")));
            data.put("rentDate", orderdetail.getRentDate());
            data.put("endRentDate", new Date());
            data.put("prepaidRent", orderdetail.getPrepaidRent().toString());
            data.put("orderTime", order.getCreateTime());
            jsonResult(1, "", "获取商品详情成功", data, response);

            return;
        }catch (Exception e){
            e.printStackTrace();
            jsonResult(0, "99", "程序出错", "", response);
            return;
        }
    }
    //

    /**
     * 生成订单
     * @param req
     * @param resp
     * @param model
     * @throws Exception
     */
    @RequestMapping("/generateOrder.jn")
    public void generateOrder(@RequestParam(required = true) Integer userinfoId,//用户id
                              @RequestParam(required = true) Integer count,//支付物品数量
                              @RequestParam(required = true) String commodityId,//支付物品id
                              @RequestParam(required = true) Integer objectType,//支付目标
                              @RequestParam(required = false) Integer minPrepaidRent,//预租天数
                              @RequestParam(required = true) String distributionId,//选择配送地址的id
                              @RequestParam(required = false) String remarks,//配送备注
                              @RequestParam(required = false) String orderNum,//未支付的订单号，就是要删除的订单号
                              HttpServletRequest req, HttpServletResponse resp,
                              ModelMap model) throws Exception {
        try{
            if(count==null||count==0){
                count=1;
            }

            String orderCode = null;
            String title = "";
            BigDecimal salePrice = null;
            Integer orderType =null;
            String businessId = "";

            Integer status = 0;
            Map<String,Object> map = new HashMap<String, Object>();
            map.put("isuse",0);
            map.put("objectId", commodityId);
            map.put("objectType",objectType);

            Map<String, Object> mapu = new HashMap<>();
            mapu.put("userinfoId",userinfoId);
            Identitycard idcard = identitycardService.queryByOne(mapu);
            if(idcard!=null&&idcard.getStatus()==1){

            }else{
                jsonResult(0,"40","身份验证没通过","",resp);
                return;
            }
            Czjcommodity czjcommodity = czjcommodityService.queryById(commodityId);
            if(czjcommodity==null){
                jsonResult(0,"41","商品不存在，或者商品已下架","",resp);
                return;
            }
            BigDecimal prepaidRent = null;
            if(objectType==1){//生成租赁预付
                orderCode = OrderNumUtils.getOrderNo(1);
                if(minPrepaidRent==null){
                    jsonResult(0,"47","预付天数不能为空!","",resp);
                    return;
                }
                prepaidRent = czjcommodity.getDailyRent().multiply(new BigDecimal(minPrepaidRent));
                salePrice = prepaidRent;
                status=OrderStatus.STAYINADVANCE.getIndex();
            }else if(objectType==2){//生成商品订单
                orderCode = OrderNumUtils.getOrderNo(2);
                salePrice = czjcommodity.getPresentPrice();
                status=OrderStatus.TOBUY.getIndex();

            }else{
                jsonResult(0,"45","不是商品或者活动!","",resp);
                return;
            }

            title = czjcommodity.getCommodityName();
            businessId = czjcommodity.getBusinessId();
            orderType = OrderType.COMMODITY.getIndex();

            map.put("salePrice",salePrice.toString());

            Czjorder czjorder = new Czjorder();
            czjorder.setPurchaseOrLease(objectType);
            Czjorderdetail czjorderdetail = new Czjorderdetail();
            Czjorderdistribution czjorderdistribution = new Czjorderdistribution();
            //订单
            czjorder.setUserinfoId(userinfoId);
            czjorder.setId(UUIDUtils.getUUID());
            czjorder.setCreateTime(new Date());
            czjorder.setOrderType(orderType);
            czjorder.setBusinessId(businessId);
            czjorder.setOrderCode(orderCode);
            czjorder.setPaymentType(0);
            czjorder.setTotalAmount(salePrice.multiply(new BigDecimal(count)));
            czjorder.setStatus(status);



            if(czjorder.getTotalAmount().compareTo(BigDecimal.ZERO)==0){
                status=1;


            }

            //订单详情
            czjorderdetail.setOrderCode(orderCode);
            czjorderdetail.setId(UUIDUtils.getUUID());
            czjorderdetail.setCreateTime(new Date());
            czjorderdetail.setAmount(count);
            czjorderdetail.setCommodityId(commodityId);
            czjorderdetail.setSalePrice(salePrice);
            czjorderdetail.setTitle(title);

            czjorderdetail.setDailyRent(czjcommodity.getDailyRent());
            czjorderdetail.setPrepaidRent(czjcommodity.getPrepaidRent());



            czjorderdetail.setMinPrepaidRent(minPrepaidRent);
            czjorderdetail.setPrepaidRent(prepaidRent);

            czjorderdetailService.checkEntity(czjorderdetail);
            czjorderService.checkEntity(czjorder);
            if(StringUtils.isNotBlank(distributionId)){
                //订单配送地址
                Czjdeliveryadd deliveryadd = czjdeliveryaddService.queryById(distributionId);
                if(deliveryadd==null){
                    jsonResult(0,"46","配送地址不存在","",resp);
                    return;
                }
                czjorderdistribution.setId(UUIDUtils.getUUID());
                czjorderdistribution.setAddress((deliveryadd.getRegion()==null?"":deliveryadd.getRegion())+" "+(deliveryadd.getAddress()==null?"":deliveryadd.getAddress()));
                czjorderdistribution.setCreateTime(new Date());
                czjorderdistribution.setEmail(null);
                czjorderdistribution.setPhoneNo(deliveryadd.getPhone());
                czjorderdistribution.setOrderCode(orderCode);
                czjorderdistribution.setPostalCode(null);
                czjorderdistribution.setRecipients(deliveryadd.getName());
                czjorderdistribution.setMessage(remarks);
                czjorderdistributionService.checkEntity(czjorderdistribution);
                czjorderdistributionService.insert(czjorderdistribution);

            }else{
                jsonResult(0,"40","收货地址必须要选","",resp);
                return;
            }
            czjorderdetailService.insert(czjorderdetail);
            czjorderService.insert(czjorder);
            //0元支付情况，支付金额为0情况，订单自动完成
            if(status==1){

                //增加已售量
                Czjcommodity comodity = czjcommodityService.queryById(czjorderdetail.getCommodityId());
                if(comodity.getSoldOut()==null){
                    comodity.setSoldOut(0);
                }
                if(czjorderdetail.getAmount()==null){
                    czjorderdetail.setAmount(0);
                }
                comodity.setSoldOut(comodity.getSoldOut()+czjorderdetail.getAmount());
                 /*   comodity.setInventory(comodity.getInventory()-czjorderdetail.getAmount());
                    if(comodity.getInventory()<0){
                        jsonResult(0,"65","该商品已售完","",resp);
                        return;
                    }*/
                czjcommodityService.update(comodity);
                Czjorderdistribution orderdistribution = czjorderdistributionService.getByOrderno(orderCode);

                if(orderdistribution==null){
                    if(status==OrderStatus.STAYINADVANCE.getIndex()){
                        czjorderService.updateOrderStatus(orderCode,OrderStatus.CONFIRMRECEIPT.getIndex());
                    }else{
                        czjorderService.updateOrderStatus(orderCode,OrderStatus.FIN.getIndex());
                    }

                }
            }
            map.put("price", czjorder.getTotalAmount().toString());

            map.put("orderno", orderCode);
            map.put("status", status);
            deleteByOrderCode(orderNum,userinfoId);
            jsonResult(1,"","生成订单",map,resp);
            return;
        }catch (Exception e){
            e.printStackTrace();
            log.error("#error:",e);
            jsonResult(0,"99","生成订单失败","",resp);
            return;
        }

    }
    //生成订单时，删除旧订单
    private void deleteByOrderCode(String orderNo, Integer userinfoId) {
        try{
            if(StringUtils.isBlank(orderNo)){
                return ;
            }
            Map<String, Object> param = new HashMap<>();
            param.put("orderCode", orderNo);
            Czjorder order = czjorderService.getOneBy(param);
            if(order==null){
                System.err.println("订单号不存在");
                return ;
            }
            if(userinfoId.equals(order.getUserinfoId())){
                if(OrderStatus.TOBUY.getIndex()==order.getStatus()||OrderStatus.STAYINADVANCE.getIndex()==order.getStatus()){
                    czjorderService.deleteAllByOrderCode(orderNo);
                    System.out.println("订单取消成功");
                    return ;
                }else{
                    System.err.println("该订单状态不允许取消订单");
                    return ;
                }

            }
            System.err.println("订单号和用户匹配不上");
        }catch (Exception e){
            System.err.println("生成订单时，删除订单失败");
        }
    }
    //结算租赁（结束租赁计算付费金额）
    @RequestMapping("/genernateLease.jn")
    public void genernateLease(@RequestParam(required = true) Integer userinfoId,//用户id
                               @RequestParam(required = true) String orderNo,//订单号
                               HttpServletRequest req, HttpServletResponse resp,
                               ModelMap model) throws Exception {
        try{
            Map<String, Object> mapu = new HashMap<>();
            mapu.put("userinfoId",userinfoId);
            Identitycard idcard = identitycardService.queryByOne(mapu);
            if(idcard!=null&&idcard.getStatus()==1){

            }else{
                jsonResult(0,"40","身份验证没通过","",resp);
                return;
            }
            Map<String, Object> param = new HashMap<>();
            param.put("orderCode", orderNo);
            Czjorder order = czjorderService.getOneBy(param);
            if(!order.getUserinfoId().equals(userinfoId)){
                jsonResult(0,"331","订单号和用户匹配不上","",resp);
                return;
            }
            if(order.getStatus()!=OrderStatus.INLEASE.getIndex()){//待结束租赁
                jsonResult(0, "324", "该订单状态不能执行结束租赁", "", resp);
                return;
            }
            Map<String,Object> datakey = czjorderService.getEndLeasePrice(orderNo);
            if((Integer)datakey.get("status")==0){
                jsonResult(0,(String)datakey.get("code"),(String)datakey.get("msg"),datakey.get("result"),resp);
                return;
            }
            String orderCode = OrderNumUtils.getOrderNo(3);
            Map<String, Object> map = new HashMap<>();
            BigDecimal price = (BigDecimal) datakey.get("price");
            map.put("price", ((BigDecimal)datakey.get("price")).toString());

            map.put("orderno", orderCode);
            Integer status = 0;
            if(price.compareTo(BigDecimal.ZERO)<=0){
                status =1 ;//1为0元支付
            }
            map.put("status", status);

            Czjorderdetail orderdetail = czjorderdetailService.queryByCode(orderNo);
            if (orderdetail == null) {
                jsonResult(0, "322", "订单详情不存在", "", resp);
               return;
            }
            Czjcommodity czjcommodity = czjcommodityService.queryById(orderdetail.getCommodityId());
            if(czjcommodity==null){
                jsonResult(0,"41","商品不存在","",resp);
                return;
            }
            Map<String, Object> result = (Map<String, Object>) datakey.get("result");
            Czjorderdetail czjorderdetail = new Czjorderdetail();
            czjorderdetail.setEndLeaseAmount(price);
            czjorderdetail.setEndLeaseNum(orderCode);
            czjorderdetail.setEndRentDate(new Date());
            czjorderdetail.setLeaseDays((Integer)result.get("usedate"));
            czjorderdetail.setLeasejisuanDays((Integer)result.get("beyond"));
            czjorderdetail.setId(orderdetail.getId());
            czjorderdetailService.update(czjorderdetail);
            if(status==1){
                Czjorder czjorder = new Czjorder();
                czjorder.setId(order.getId());
                czjorder.setStatus(OrderStatus.FINENDLEASE.getIndex());
                czjorderService.update(czjorder);
            }
            jsonResult(1,"","生成订单",map,resp);
            return;
        }catch (Exception e){
            e.printStackTrace();
            log.error("#error:",e);
            jsonResult(0,"99","生成订单失败","",resp);
            return;
        }

    }
    /**
     * 获得物流信息
     * 方法名：getExpressBycode
     * 创建人：RUI
     * 时间：2017年7月6日-下午2:06:40
     * @param orderCode
     * @param req
     * @param resp
     * @param model
     * @throws Exception void
     * @exception
     * @since  1.0.0
     */
    @RequestMapping("/getExpressBycode")
    public void getExpressBycode(@RequestParam(required=true) String orderCode,HttpServletRequest req, HttpServletResponse resp,
                                 ModelMap model) throws Exception {

        try {
            Map<String,Object> map=new HashMap<String, Object>();
            map.put("status", Expresstatus.DELIVER.getIndex());
            map.put("orderCode", orderCode);
            Czjexpress czjexpress=czjexpressService.getExpressByOrdercode(map);
            jsonResult(1, "", "", czjexpress, resp);
        } catch (Exception e) {
            e.printStackTrace();
            jsonResult(0, "154", "查询商品物流信息失败", "", resp);
        }

    }
    //订单列表
    @RequestMapping("/list.jn")
    public void list(@RequestParam(required = true)Integer userinfoId, Integer pageNo,Integer pageSize,
                     HttpServletRequest req, HttpServletResponse resp,
                                 ModelMap model) throws Exception {

        try {

            Czjuserinfo userinfo = czjuserinfoService.queryByUserinfoId(userinfoId);
            if(userinfo==null){
                jsonResult(0, "346", "用户不存在", "", resp);
                return;
            }
            Map<String,Object> map=new HashMap<String, Object>();
            if(pageSize==null){
                pageSize=10;
            }
            map.put("userinfoId",userinfoId);
            Pagination pagination = czjorderService.getApiList(pageNo, pageSize, map, model);


            for (int i = 0; i < pagination.getList().size(); i++) {
                Map<String,Object> data = (Map<String,Object>)pagination.getList().get(i);
                Integer status = (Integer)data.get("status");
                data.put("statusName",OrderStatus.getName(status));
                //计算租赁日期
                if(OrderStatus.INLEASE.getIndex()==status) {
                    Czjorderdetail czjorderdetail = new Czjorderdetail();
                    czjorderdetail.setRentDate((Date) data.get("rentDate"));//开始计算日期
                    czjorderdetail.setDailyRent((BigDecimal) data.get("dailyRent"));//日租金;
                    czjorderdetail.setPrepaidRent((BigDecimal) data.get("prepaidRent"));//预付租金
                    czjorderdetail.setMinPrepaidRent((Integer) data.get("minPrepaidRent"));//起租天数
                    czjorderdetail.setAmount((Integer) data.get("amount"));
                    Map<String, Object> moneydata = czjorderdetailService.jisuanMoney(czjorderdetail);
                    BigDecimal money = (BigDecimal) moneydata.get("money");
                    Integer usedate = (Integer) moneydata.get("usedate");
                    data.put("money", money);
                    data.put("usedate", usedate);
                    data.put("nowDate", new Date());
                }
                data.remove("userinfoId");

            }
            jsonResult(1, "", "", pagination, resp);
        } catch (Exception e) {
            e.printStackTrace();
            jsonResult(0, "99", "查询订单列表失败", "", resp);
        }

    }
    
    /**
     * 
     * 方法名：getBusinPhone 获得商家电话
     * 创建人：RUI
     * 时间：2017年7月6日-下午2:14:47 
     * @param businessId
     * @param req
     * @param resp
     * @param model
     * @throws Exception void
     * @exception 
     * @since  1.0.0
     */
    @RequestMapping("/getBusinPhone")
    public void getBusinPhone(@RequestParam(required=true) String businessId,HttpServletRequest req, HttpServletResponse resp,
                      ModelMap model) throws Exception {
    	
    	try {
    		Czjbusiness czjbusiness=czjbusinessService.queryById(businessId);
			jsonResult(1, "", "", czjbusiness, resp);
		} catch (Exception e) {
			e.printStackTrace();
			jsonResult(0, "156", "获取商家信息错误", "", resp);
		}
    	
    }

}
